import api from '../common/api.js'
import store from '../store/index'
const Share = {
    shareCode: '',
    getShareCode() {
        return api.getShareCode().then((res) => {
            if (res.code == 200) {
                this.shareCode = res.data.code;
                return res.data.code
            }
        });
    },

    getShareId({ from, shareLink, shareTitle, shareImgUrl = "", id }) {
        let type = from === "button" ? 1 : 2;
        api.getShareId({
            type,
            share_link: shareLink,
            share_code: this.shareCode,
        })
        console.log(`/${shareLink}?id=${id}&shareCode=${this.shareCode}&userId=${store.state.userInfo.id}`);
        return {
            title: shareTitle,
            path: `/${shareLink}?id=${id}&shareCode=${this.shareCode}&userId=${store.state.userInfo.id}`,
            imageUrl: shareImgUrl
        };
    },
}
export default Share